package top.superflow.core.pool.resource.factory.defaults


import top.superflow.core.pool.imp.ResourcePoolConfig
import top.superflow.core.pool.resource.ResourcePool
import top.superflow.core.pool.resource.factory.ResourcePoolFactory
import top.superflow.exception.RequestUnsupportedException
import top.superflow.lang.StringUtils

class DefaultResourcePoolFactory private () extends ResourcePoolFactory[ResourcePoolConfig]{

  def create(configuration: ResourcePoolConfig): ResourcePool[_] = {

    validateConfig(configuration)
    null


  }

  private def validateConfig(configuration: ResourcePoolConfig): Unit = {
    if(configuration == null){
      throw new RequestUnsupportedException("The configuration of the pool should not be null when you create a new resource pool!")
    }

    if(StringUtils.isBlank(configuration.getKey)){
      throw new RequestUnsupportedException("The key of the resource pool should not be null!")
    }

    //other validation
  }
  
}

object DefaultResourcePoolFactory {
  private val instance = new DefaultResourcePoolFactory
  
  def getInstance = instance
}